package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class PlayActivity extends AppCompatActivity {

    VideoView vvContext;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play);

        vvContext=findViewById(R.id.vvContext);

        Intent intent=getIntent();
        int data=intent.getIntExtra("data",0);
        if (data != 0) {

            MediaController controller=new MediaController(this);

            vvContext.setMediaController(controller);
            vvContext.setVideoURI(Uri.parse("android.resource://com.example.myapplication/"+data));

            vvContext.start();
        }else {
            finish();
        }
    }
}
